<?php

namespace App\Http\Requests\Article;

use Illuminate\Foundation\Http\FormRequest;

class ListRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules()
    {
        return [
            'page_no'   => 'sometimes|integer|nullable|min:1',
            'page_size' => 'sometimes|integer|nullable|min:1|max:100',
            'type'      => 'sometimes|in:open,policy,hot,history,foot,honor',
            'sub_type'  => 'required_if:type,open|nullable|in:audit,check,notice'
        ];
    }

    public function messages()
    {
        return [
            'page_no.min'     => '最小为1页',
            'page_size.min'   => '最小为1条',
            'page_size.max'   => '最大为100页',
            'type.in'         => 'Type不在取值范围内',
            'sub_type.in'     => 'SubType不在取值范围内'
        ];
    }
}
